package com.yyq.common;

import sun.applet.Main;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;

/**
 * @author yyq
 * @create 2021-08-03 16:34
 */
public class Yyq_Date {
    public static void main(String[] args) throws ParseException {
        //实例化
        Calendar calendar=Calendar.getInstance();
        //get
        int i = calendar.get(Calendar.DAY_OF_MONTH);
        System.out.println(i);
        int i1 = calendar.get(Calendar.DAY_OF_YEAR);
        System.out.println(i1);
        //set
        calendar.set(Calendar.DAY_OF_YEAR,11);
        i = calendar.get(Calendar.DAY_OF_MONTH);
        System.out.println(i);
        //add
        calendar.add(Calendar.DAY_OF_YEAR,11);
        i = calendar.get(Calendar.DAY_OF_MONTH);
        System.out.println(i);
        //gettime
        Date time = calendar.getTime();
        System.out.println(time);

        //settime
        Date date = new Date();
        calendar.setTime(date);
        time = calendar.getTime();
        System.out.println(time);
    }
}